<template>
  <EvDialog :title="'选择对象组'" :dialogVisible="dialogVisible" width="45%" @handleClose="handleDialogClose"
    @handleCancel="handleDialogCancel" @handleConfirm="handleDialogConfirm">
    <EvTable ref="reciverGroupTable" :options="{ data, columns, height: '300', toolbarConfig: { custom: false } }" :tablePage="page">
    </EvTable>
  </EvDialog>
</template>
<script>
import EvDialog from "@/components/EvDialog/index.vue";
export default {
  components: {
    EvDialog
  },
  data() {
    return {
      dialogVisible: false,
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      // 对象组表格
      data: [],
      columns: [
        { type: 'checkbox', fixed: 'left', align: 'center', width: 50 },
        { title: '序号', fixed: 'left', align: 'center', width: 60, type: 'seq' },
        { title: '对象组名称', field: 'groupName', align: 'left' },
        { title: '对象组编号', field: 'groupCode', align: 'left' },
      ],
    }
  },
  mounted() {
    this.loadData()
  },
  methods: {
    // 加载数据
    loadData() {
      console.log('执行加载数据');
      this.$server().query("function-andon-provider", "ObjectGroup", null, null, { current: this.page.currentPage, size: this.page.pageSize }, true)
        .then(response => {
          this.page.total = response.total;
          this.data = response.list
        })
        .catch(response => {
          this.$message.error(response.data.message);
        });
    },
    open() {
      this.dialogVisible = true
    },
    handleDialogCancel() {
      this.dialogVisible = false
    },
    handleDialogClose() {
      this.dialogVisible = false
    },
    handleDialogConfirm() {
      this.dialogVisible = false
      this.$emit('handleCheckConfirm',this.$refs.reciverGroupTable.getSelectRecords())
    },
  }
}
</script>
<style lang="scss" scoped></style>